package sh.set;

import java.util.HashMap;

public class HashSet implements Set {
    private transient HashMap map;
    private static final Object PRESENT = new Object();
    public HashSet() {
        this.map = new HashMap();

    }


    @Override
    public int size() {
        return map.size();
    }

    @Override
    public void add(Object obj) {
        map.put(obj,PRESENT);
    }

    @Override
    public boolean isEmpty() {
        // 在hashMap里面就是  return size == 0;
        return map.isEmpty();
    }

    @Override
    public boolean contains(Object obj) {
        return map.get(obj)!=null;
    }
}
